<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>win10子系统上的ubuntu上安装docker | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="1 更换国内软件源，推荐中国科技大学的源，稳定速度较快。12345sudo cp &#x2F;etc&#x2F;apt&#x2F;sources.list &#x2F;etc&#x2F;apt&#x2F;sources.list.baksudo sed -i &#39;s&#x2F;archive.ubuntu.com&#x2F;mirrors.ustc.edu.cn&#x2F;g&#39; &#x2F;etc&#x2F;apt&#x2F;sources.listsudo apt update  2 安装需要的包1sudo apt">
<meta property="og:type" content="article">
<meta property="og:title" content="win10子系统上的ubuntu上安装docker">
<meta property="og:url" content="http://yoursite.com/2020/07/15/ubuntu%E4%B8%8A%E5%AE%89%E8%A3%85docker/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="1 更换国内软件源，推荐中国科技大学的源，稳定速度较快。12345sudo cp &#x2F;etc&#x2F;apt&#x2F;sources.list &#x2F;etc&#x2F;apt&#x2F;sources.list.baksudo sed -i &#39;s&#x2F;archive.ubuntu.com&#x2F;mirrors.ustc.edu.cn&#x2F;g&#39; &#x2F;etc&#x2F;apt&#x2F;sources.listsudo apt update  2 安装需要的包1sudo apt">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-07-15T13:21:07.000Z">
<meta property="article:modified_time" content="2020-07-20T12:57:13.615Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="docker">
<meta property="article:tag" content="ubuntu">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/css/style.css">

<meta name="generator" content="Hexo 4.2.1"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-ubuntu上安装docker" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2020/07/15/ubuntu%E4%B8%8A%E5%AE%89%E8%A3%85docker/" class="article-date">
  <time datetime="2020-07-15T13:21:07.000Z" itemprop="datePublished">2020-07-15</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      win10子系统上的ubuntu上安装docker
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="1-更换国内软件源，推荐中国科技大学的源，稳定速度较快。"><a href="#1-更换国内软件源，推荐中国科技大学的源，稳定速度较快。" class="headerlink" title="1 更换国内软件源，推荐中国科技大学的源，稳定速度较快。"></a>1 更换国内软件源，推荐中国科技大学的源，稳定速度较快。</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak</span><br><span class="line"></span><br><span class="line">sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list</span><br><span class="line"></span><br><span class="line">sudo apt update</span><br></pre></td></tr></table></figure>

<h3 id="2-安装需要的包"><a href="#2-安装需要的包" class="headerlink" title="2 安装需要的包"></a>2 安装需要的包</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt install apt-transport-https ca-certificates software-properties-common curl</span><br></pre></td></tr></table></figure>



<h3 id="3-添加GPG密钥，并添加Docker-ce软件源，这里还是以中国科技大学的Docker-ce源为例："><a href="#3-添加GPG密钥，并添加Docker-ce软件源，这里还是以中国科技大学的Docker-ce源为例：" class="headerlink" title="3 添加GPG密钥，并添加Docker-ce软件源，这里还是以中国科技大学的Docker-ce源为例："></a>3 添加GPG密钥，并添加Docker-ce软件源，这里还是以中国科技大学的Docker-ce源为例：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -</span><br><span class="line">sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \</span><br><span class="line"><span class="meta">$</span><span class="bash">(lsb_release -cs) stable<span class="string">"</span></span></span><br></pre></td></tr></table></figure>

<h3 id="4-添加成功后更新软件包缓存"><a href="#4-添加成功后更新软件包缓存" class="headerlink" title="4 添加成功后更新软件包缓存"></a>4 添加成功后更新软件包缓存</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt update</span><br></pre></td></tr></table></figure>



<h3 id="5-安装-Docker-ce"><a href="#5-安装-Docker-ce" class="headerlink" title="5 安装 Docker-ce"></a>5 安装 Docker-ce</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt install docker-ce</span><br></pre></td></tr></table></figure>

<h3 id="6-设置开机自启动并启动-Docker-ce（安装成功后默认已设置并启动，可忽略）"><a href="#6-设置开机自启动并启动-Docker-ce（安装成功后默认已设置并启动，可忽略）" class="headerlink" title="6.设置开机自启动并启动 Docker-ce（安装成功后默认已设置并启动，可忽略）"></a>6.设置开机自启动并启动 Docker-ce（安装成功后默认已设置并启动，可忽略）</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl enable docker</span><br><span class="line">sudo systemctl start docker</span><br></pre></td></tr></table></figure>

<h3 id="7-测试运行"><a href="#7-测试运行" class="headerlink" title="7.测试运行"></a>7.测试运行</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo docker run hello-world</span><br></pre></td></tr></table></figure>

<h3 id="8-添加当前用户到-docker-用户组，可以不用-sudo-运行-docker（可选）"><a href="#8-添加当前用户到-docker-用户组，可以不用-sudo-运行-docker（可选）" class="headerlink" title="8.添加当前用户到 docker 用户组，可以不用 sudo 运行 docker（可选）"></a>8.添加当前用户到 docker 用户组，可以不用 sudo 运行 docker（可选）</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo groupadd docker</span><br><span class="line">sudo usermod -aG docker $USER</span><br></pre></td></tr></table></figure>

<h3 id="9-测试添加用户组（可选）"><a href="#9-测试添加用户组（可选）" class="headerlink" title="9.测试添加用户组（可选）"></a>9.测试添加用户组（可选）</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run hello-world</span><br></pre></td></tr></table></figure>


      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/07/15/ubuntu%E4%B8%8A%E5%AE%89%E8%A3%85docker/" data-id="ckcqayu8p0002u4v1bihc9kjq" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/docker/" rel="tag">docker</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/ubuntu/" rel="tag">ubuntu</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2020/07/15/docker%E4%B8%8B%E8%BF%90%E8%A1%8Cmysql/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          docker上运行MySQL
        
      </div>
    </a>
  
  
    <a href="/2020/07/09/unbutu%E4%B8%8B%E7%BC%96%E8%AF%91openjdk13/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">unbutu下编译openjdk13</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/docker/">docker</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/docker/fastdfs/">fastdfs</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/docker/mysql/">mysql</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/idea/">idea</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/idea/github/">github</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/java/">java</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/win10/">win10</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/win10/hyper-v/">hyper-v</a></li></ul></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/MySQL/" rel="tag">MySQL</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/canal/" rel="tag">canal</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker/" rel="tag">docker</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/fastdfs/" rel="tag">fastdfs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/github/" rel="tag">github</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gui/" rel="tag">gui</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hyper-v/" rel="tag">hyper-v</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/idea/" rel="tag">idea</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/" rel="tag">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/log/" rel="tag">log</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lua/" rel="tag">lua</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/" rel="tag">nginx</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/openresty/" rel="tag">openresty</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/port/" rel="tag">port</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/redis/" rel="tag">redis</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ubuntu/" rel="tag">ubuntu</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/win10/" rel="tag">win10</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/windows10/" rel="tag">windows10</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wsl/" rel="tag">wsl</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wsl1/" rel="tag">wsl1</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wsl2/" rel="tag">wsl2</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/MySQL/" style="font-size: 12.5px;">MySQL</a> <a href="/tags/canal/" style="font-size: 12.5px;">canal</a> <a href="/tags/docker/" style="font-size: 17.5px;">docker</a> <a href="/tags/fastdfs/" style="font-size: 10px;">fastdfs</a> <a href="/tags/github/" style="font-size: 10px;">github</a> <a href="/tags/gui/" style="font-size: 10px;">gui</a> <a href="/tags/hyper-v/" style="font-size: 10px;">hyper-v</a> <a href="/tags/idea/" style="font-size: 10px;">idea</a> <a href="/tags/java/" style="font-size: 15px;">java</a> <a href="/tags/log/" style="font-size: 10px;">log</a> <a href="/tags/lua/" style="font-size: 12.5px;">lua</a> <a href="/tags/nginx/" style="font-size: 10px;">nginx</a> <a href="/tags/openresty/" style="font-size: 15px;">openresty</a> <a href="/tags/port/" style="font-size: 10px;">port</a> <a href="/tags/redis/" style="font-size: 10px;">redis</a> <a href="/tags/ubuntu/" style="font-size: 20px;">ubuntu</a> <a href="/tags/win10/" style="font-size: 12.5px;">win10</a> <a href="/tags/windows10/" style="font-size: 10px;">windows10</a> <a href="/tags/wsl/" style="font-size: 10px;">wsl</a> <a href="/tags/wsl1/" style="font-size: 10px;">wsl1</a> <a href="/tags/wsl2/" style="font-size: 12.5px;">wsl2</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/08/">August 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/07/">July 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2020/08/11/Mysql-Host-is-blocked-because-of-many-connection-errors/">Mysql Host is blocked because of many connection errors</a>
          </li>
        
          <li>
            <a href="/2020/08/08/canal%E5%90%8C%E6%AD%A5MySQL%E6%95%B0%E6%8D%AE%E9%85%8D%E7%BD%AE/">canal同步MySQL数据配置</a>
          </li>
        
          <li>
            <a href="/2020/08/03/docker%E4%B8%8Acanal%E5%AE%B9%E5%99%A8%E7%9A%84%E5%AE%89%E8%A3%85/">docker上canal容器的安装</a>
          </li>
        
          <li>
            <a href="/2020/08/03/MySQL%E5%BC%80%E5%90%AFbinlog%E6%97%A5%E5%BF%97%E6%A8%A1%E5%BC%8F/">MySQL开启binlog日志模式</a>
          </li>
        
          <li>
            <a href="/2020/08/01/openresty%E4%BD%BF%E7%94%A8lua%E8%84%9A%E6%9C%AC%E5%AE%9E%E7%8E%B0%E5%B9%BF%E5%91%8A%E7%BC%93%E5%AD%98/">openresty使用lua脚本实现广告缓存.md</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">

  
<script src="/fancybox/jquery.fancybox.pack.js"></script>




<script src="/js/script.js"></script>




  </div>
</body>
</html>